package haiyangwangwork.day10.第一组.杨琳.ex2;

import java.util.Scanner;

public class Demo3 {
//    已知一个顺序从小到大的整型数组{12, 23, 34, 45, 56, 67, 78, 89}，用户输入一个数字，把它放入到正确的位置中，其他元素也要保留。
public static void main(String[] args) {
    int[] array = new int[]{12, 23, 34, 45, 56, 67, 78, 89,0};
    Scanner input = new Scanner(System.in);
    System.out.println("请输入一个数");
    int num = input.nextInt();
    int[] newArray = new int[array.length + 1];
    for (int i = 0;i<array.length;i++){
        newArray[i]=array[i];
    }

    //冒泡排序
    for (int j = 0;j< newArray.length-1;j++){
        for (int k = 0;k<newArray.length-1-j;k++){
            int temp;
            temp = newArray[k];
            newArray[k]=newArray[k+1];
            newArray[k+1]=temp;
        }
    }
    for (int i=0;i<array.length;i++){
        System.out.println(array[i]);
    }

    }
}

